package com.vf.admin.miaodong.controller;

import com.vf.admin.common.BaseController;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppRoomLaHei;
import com.vf.admin.miaodong.entity.AppUserLaHei;
import com.vf.admin.miaodong.service.AfterRoomLaHeiService;
import com.vf.admin.miaodong.service.AfterUserLaHeiService;
import com.vf.admin.utils.StringEx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author anxiang
 * @version 1.0.0
 * @ClassName AfterLaHeiController.java
 * @Description 拉黑管理
 * @createTime 2021年11月04日 17:11:00
 */

@Controller
@RequestMapping("/after/lahei")
public class AfterLaHeiController extends BaseController {

    @Autowired
    AfterUserLaHeiService afterUserLaHeiService;
    @Autowired
    AfterRoomLaHeiService afterRoomLaHeiService;


    /**
     * @Description 用户拉黑列表
     * @Param: [splitPageBean]
     * @return: java.lang.String
     * @Author: ljx
     * @Date: 2021/07/4
     */
    @RequestMapping("/userlahei")
    public String userlahei(SplitPageBean splitPageBean, String nick, String lhnick) {
        try {

            Map<String, Object> map = new HashMap<>();
            if (StringEx.isNotNull(nick)) {
                map.put("nick", nick);
            }

            if (StringEx.isNotNull(lhnick)) {
                map.put("lhnick", lhnick);
            }

            List<AppUserLaHei> appUserLaHeiList = afterUserLaHeiService.findList(map, splitPageBean);
            request.setAttribute("list", appUserLaHeiList);
            request.setAttribute("splitPage", splitPageBean);
            return this.sucess("/web/after/lahei/userlist");
        } catch (Exception e) {
            e.printStackTrace();
            return this.error("系统繁忙");
        }
    }

    /**
     * @Description 房间拉黑列表
     * @Param: [splitPageBean]  nick 拉黑的用户昵称  roomname 房间名字
     * @return: java.lang.String
     * @Author: ljx
     * @Date: 2021/07/4
     */
    @RequestMapping("/roomlahei")
    public String roomlahei(SplitPageBean splitPageBean, String nick, String roomname) {
        try {
            Map<String, Object> map = new HashMap<>();
            if (StringEx.isNotNull(nick)) {
                map.put("nick", nick);
            }
            if (StringEx.isNotNull(roomname)) {
                map.put("roomname", roomname);
            }
            List<AppRoomLaHei> appRoomLaHeiList = afterRoomLaHeiService.findList(map, splitPageBean);
            request.setAttribute("list", appRoomLaHeiList);
            request.setAttribute("splitPage", splitPageBean);
            return this.sucess("/web/after/lahei/roomlist");
        } catch (Exception e) {
            e.printStackTrace();
            return this.error("系统繁忙");
        }
    }
}